package cn.iocoder.yudao.module.book.dal.mysql.community;

import java.util.*;

import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.book.dal.dataobject.community.PostImagesDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 动态图片 Mapper
 *
 * @author system
 */
@Mapper
public interface PostImagesMapper extends BaseMapperX<PostImagesDO> {

    /**
     * 根据动态ID查询图片列表
     */
    default List<PostImagesDO> selectByPostId(Long postId) {
        return selectList(new LambdaQueryWrapperX<PostImagesDO>()
                .eq(PostImagesDO::getPostId, postId)
                .orderByAsc(PostImagesDO::getImageOrder));
    }

    /**
     * 根据动态ID删除图片
     */
    default int deleteByPostId(Long postId) {
        return delete(new LambdaQueryWrapperX<PostImagesDO>()
                .eq(PostImagesDO::getPostId, postId));
    }

    /**
     * 批量插入图片
     */
    int insertBatch(@Param("images") List<PostImagesDO> images);

}
